﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Customer
/// </summary>
public class Customer
{
    #region Properties
    public Guid CustomerID { get; set; }
    public string CustomerCode { get; set; }
    public string CustomerName { get; set; }
    public string Email { get; set; }
    public string Address { get; set; }
    public string Phone { get; set; }
    public Employee LastUser { get; set; }
    public DateTime LastUpdate { get; set; }
    public MonthCard MonthCard { get; set; }
    #endregion
    public Customer()
	{
		//
		// TODO: Add constructor logic here
		//
        this.CustomerID = Guid.Empty;
        this.CustomerCode = String.Empty;
        this.CustomerName = String.Empty;
        this.Email = String.Empty;
        this.Address = String.Empty;
        this.Phone = String.Empty;
        this.LastUser = null;
        this.LastUpdate = DateTime.Now;
        this.MonthCard = null;
	}

    /// <summary>
    /// GetAll
    /// </summary>
    /// <returns>List<Customer></returns>
    public IList<Customer> GetAll()
    {
        try
        {
            return CustomerDAL.GetAll();
        }
        catch (Exception)
        {
            throw;
        }
    }


    /// <summary>
    /// 
    /// </summary>
    /// <param name="id">Guid</param>
    /// <returns>Customer</returns>
    public Customer GetById(Guid id)
    {
        try
        {
            return CustomerDAL.GetById(id);
        }
        catch (Exception)
        {
            throw;
        }
    }

    public IList<Customer> GetByCustomer()
    {
        return CustomerDAL.GetByCustomer(this);
    }
    public IList<Customer> GetByCustomerPaging(int page,int pageSize)
    {
        return CustomerDAL.GetByCustomerPaging(this,page,pageSize);
    }
    public int GetByCustomerPagingTotal()
    {
        return CustomerDAL.GetByCustomerTotal(this);
    }

    public void Save(Customer customer)
    {
        try
        {
            CustomerDAL.Save(customer);
        }
        catch (Exception)
        {
            throw;
        }
    }

    public string GetMaxCusCode()
    {
        try
        {
            return CustomerDAL.GetMaxCusCode();
        }
        catch (Exception)
        {
            throw;
        }
    }

    public bool CanDelete(Guid id)
    {
        return CustomerDAL.CanDelete(id);
    }

    public void Delete(Guid id)
    {
        try
        {
            CustomerDAL.Delete(id);
        }
        catch (Exception)
        {
            throw;
        }
    }

    public bool IsExistedCustomerCode(string code)
    {
        try
        {
            return CustomerDAL.IsExistedCustomerCode(code);
        }
        catch (Exception)
        {
            throw;
        }
    }   
}